package com.javaEE.tes.dao;

import com.javaEE.tes.dao.dto.StudentAssociation;
import com.javaEE.tes.dao.dto.StudentClass1;
import com.javaEE.tes.entities.Student;
import com.javaEE.tes.entities.Teacher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

public interface StudentRepository extends CrudRepository<Student,Long> {

    @Autowired
    List<Student> findAll();
    @Query(nativeQuery = true,value = "SELECT s.student_num as studentNum, s.name,s.gender,c.class1Name " +
            "FROM student AS s LEFT JOIN class1 AS c ON s.class_id = c.class1id "+
            "ORDER BY s.student_num;"
    )
    List<StudentClass1> studentClass1();
    Student findByStudentId(Long theId);
    Student findByUserAccount_UserId(Long userId);
    @Query(nativeQuery = true,value = "SELECT s.student_num as studentNum FROM student AS s WHERE s.student_num = ? ")
    String findByStudentNum(String studentNum);
}

